<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ page language="java" import="com.server.web.JsVersionUtil"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript"
	src='<c:url value="/js/jquery-1.9.1.min.js"></c:url>'></script>
<script type="text/javascript"
	src='<c:url value="/js/ajaxfileupload.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script type="text/javascript"
	src='<c:url value="/js/rqfCommon/rqfCommon.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<script type="text/javascript"
	src='<c:url value="/js/rqfui/rqfui.js"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>'></script>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>?v=<%=JsVersionUtil.CURRENT_VERSION%>' />
<style>
a, ul, li, p, span, html, body {
	margin: 0;
	padding: 0;
}

a {
	text-decoration: none;
}

li {
	list-style: none;
}
/* wzw 8.3 */
.confirm_delete {
	width: 534px;
	/*height: 230px;*/
	position: absolute;
	top: 10px;
	left: calc(50% - 267px);
	background: #fff;
	box-shadow: 0 0 3px #ccc;
	border-radius: 3px;
}

.confirm_header {
	width: 534px;
	height: 34px;
	background: #2b5eae;
	border-radius: 3px;
}

.delete_course, .confirm_header>span {
	font-size: 14px;
	color: #fff;
	line-height: 34px;
	margin-left: 8px;
}

.cancel {
	width: 49px;
	height: 34px;
	float: right;
	cursor: pointer;
}

.confirm_content {
	text-align: center;
	padding: 10px;
}

.confirm_content>input {
	margin-top: 10px;
	padding: 5px 5px;
	border: 1px solid #dcdcdc;
	line-height: 140px;
	width: 90%;
	font-size: 16px;
	color: #2b5eae;
}

.delete_course {
	width: 96px;
	height: 36px;
	border-radius: 5px;
	background: #2b5eae;
	/*position: absolute;*/
	margin-top: 30px;
	margin-bottom: 10px;
	float: left;
	cursor: pointer;
}
/* wzw 8.3 */
#add_upload {
	position: relative;
	left: 50%;
	margin-left: 40px;
}
</style>
</head>

<body>
<iframe src="file:///D:/PPT_test/趣味数学游戏-数字谜.pdf.swf" frameborder="0"></iframe>
<div class="confirm_delete" >
		<div class="confirm_content">
			<input type="file" id="fileId0" name="fileName0"/>
			<div class="delete_course" id="add_upload">
				<span>上传</span>
			</div>
			<div class="delete_course" id="add_file">
				<span> + 增加附件</span>
			</div>
		</div>
	</div>

	<script type="text/javascript">
		mini.parse();
	
		var rootPath = '${rootPath}/';
		var actionType = '${actionType}';
		var actionId = '${actionId}';
		var index=1;
		var inputCount=0;
		var messageid = null;
		
		//添加附件

		$(function() {
			$("#add_upload").click(function() {
				upload();
			})
			$("#add_file").click(function(){
				index++;
				var file_html = "<input type='file' id='fileId"
					+index+"' name='fileName"+index+"'>";
				$("#add_upload").before(file_html);
			});
		});
		function upload(){
			messageid = parent.mini.loading("附件上传中...", "Loading");
			inputCount = index;
			for(var i=0; i<=index; i++){
				var value = $('#fileId'+i).val();
				if(!value){
					continue;
				}
				var id = 'fileId'+i;
				var name = 'fileName'+i;
				ajaxFileUpload(id,name,"无");
			}
		}
		function ajaxFileUpload(fileId,inputName,fileTitle) {
			$.ajaxFileUpload({
				url : rootPath + 'attach/upload/' + inputName + '/' + fileTitle
						+ '/' + actionType + '/' + actionId, //用于文件上传的服务器端请求地址
				secureuri : false, //是否需要安全协议，一般设置为false
				fileElementId : fileId, //文件上传域的ID
				dataType : 'text', //返回值类型 一般设置为json
				type : 'json',
				success : function(data) //服务器成功响应处理函数
				{
					var obj = successDataTransform(data);
					//alert(obj.isSuccess);
					inputCount --;
					if(inputCount <= 0){
						//关闭窗口
						CloseWindow("ok");
						if (messageid) {
							parent.mini.hideMessageBox(messageid);
						}
					}
				},
				error : function(data, status, e)//服务器响应失败处理函数
				{
					inputCount --;
					if(inputCount <= 0){
						//关闭窗口
						CloseWindow("ok");
						if (messageid) {
							parent.mini.hideMessageBox(messageid);
						}
					}
					//alert(e);
				}
			})
			return false;
		}
		function CloseWindow(action) {
			if (window.CloseOwnerWindow)
				return window.CloseOwnerWindow(action);
			else
				window.close();
		}
	</script>
</body>
</html>
